package cn.fornever.tools.db.assist.util;

import cn.fornever.tools.db.assist.entity.ColumnInfo;
import cn.fornever.tools.db.assist.entity.ForeignKeyInfo;
import cn.fornever.tools.db.assist.entity.PrimaryKeyInfo;
import cn.fornever.tools.db.assist.entity.TableInfo;

import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class DBServiceOracleImpl implements IDBService {

    private static class SingletonHolder{
        public static DBServiceOracleImpl instance = new DBServiceOracleImpl();
    }
    private DBServiceOracleImpl(){
    }
    public static DBServiceOracleImpl getInstance(){
        return SingletonHolder.instance;
    }

    @Override
    public List<TableInfo> getTableInfo(Connection connection, String catalog, String schemaPattern, String tableNamePattern, String[] types) {
        return DBServiceCommonImpl.getInstance().getTableInfo(connection,catalog,schemaPattern,tableNamePattern,types);
    }


    /**
     * 获取所有列的信息.
     * <p>注意,不同数据库驱动的实现略有不同,不一定支持通配符,也不一定支持null.也不一定是每一个参数都会起作用.
     *
     * @param connection        数据库连接.
     * @param catalog           数据库的catalog
     * @param schemaPattern     数据库的schema名称.
     * @param tableNamePattern  表名.不能为空字符串,必须为有确切含义的表达式,比如'%'
     * @param columnNamePattern 列名.
     * @return 符合要求的所有表的信息.如果出现异常, 则返回 {@code null}.
     */
    @Override
    public List<ColumnInfo> getColoumInfo(Connection connection, String catalog, String schemaPattern,
                                          String tableNamePattern, String columnNamePattern) {
        return DBServiceCommonImpl.getInstance().getColoumInfo(connection, catalog, schemaPattern,
                tableNamePattern, columnNamePattern);
    }

    @Override
    public List<PrimaryKeyInfo> getPrimaryKeyInfo(Connection connection, String catalog, String schemaPattern, String tableNamePattern) {
        return null;
    }

    @Override
    public List<ForeignKeyInfo> getForeignKeyInfo(Connection connection, String catalog, String schema, String tableName) {
        return null;
    }
}
